package com.traffic.fuwu.service.impl;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.traffic.fuwu.dao.VehAppDeviceMapper;
import com.traffic.fuwu.mybatis.pojo.VehAppDevice;
import com.traffic.fuwu.mybatis.pojo.VehAppDeviceExample;
import com.traffic.fuwu.service.VehAppDeviceService;

@Service
public class VehAppDeviceServiceImpl implements VehAppDeviceService {
	@Autowired
	private VehAppDeviceMapper vehAppDeviceMapper;

	@Override
	public List<VehAppDevice> getFindVehAppDevice(Map<String, Object> conditions) {
		try {
			List<VehAppDevice> list = vehAppDeviceMapper.getFindVehAppDevice(conditions);
			if (list != null && list.size() != 0) {
				return list;
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		return null;
	}

	@Override
	public int getFindVehAppDeviceCount(Map<String, Object> conditions) {
		try {
			int count = vehAppDeviceMapper.getFindVehAppDeviceCount(conditions);
			if (count != 0) {
				return count;
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		return 0;
	}

	@Override
	public void updateVehAppDevice(VehAppDevice vehAppDevice) {
		vehAppDeviceMapper.updateByPrimaryKey(vehAppDevice);

	}

	@Override
	public VehAppDevice getById(int id) {
		VehAppDeviceExample example = new VehAppDeviceExample();
		example.or().andIdEqualTo(id);
		try {
			List<VehAppDevice> list = vehAppDeviceMapper.selectByExample(example);
			if(list != null && list.size() != 0){
				VehAppDevice vehAppDevice = list.get(0);
				return vehAppDevice;
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		return null;
	}

}
